Skip to content

feat: reduce empty lines in controllers #1401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 28, 2025
Merged

feat: reduce empty lines in controllers #1401

merged 14 commits into from
Apr 28, 2025

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented May 18, 2024

before - after
Screenshot_20240518_225302

nothing major but reduces some empty lines in the generated controllers, for the looks 😄

@m1ga
Copy link
Contributor Author

m1ga commented May 18, 2024

local tests:

Finished in 354.52 seconds
2361 specs, 0 failures

but I do see the

Warning: writing junit report failed for '', 'TEST-alloygenerate.xml'. Reasons:
  Rhino attempt: java is not defined
  PhantomJs attempt: window is not defined
  NodeJS attempt: ENOENT: no such file or directory, mkdir

messages too.

@hansemannn
Copy link
Contributor

Where are they generated in the first place? Would be better to not even generate them instead of manually fixing it down the road

@m1ga
Copy link
Contributor Author

m1ga commented Apr 28, 2025

This one: https://github.com/tidev/alloy/blob/master/Alloy/commands/compile/ast/controller.js#L48 is the last code that is run in Alloy which produces the newlines. I can add .trim() there already and the new lines are gone too. So babel is adding newlines somewhere.

Having the .trim() in the compile/index file was a bit of a "safety" spot in case the other methods in the AST controller produced newlines too.

@m1ga
Copy link
Contributor Author

m1ga commented Apr 28, 2025

ohhhh. I just saw that there is an option retainLines (https://github.com/tidev/alloy/blob/master/Alloy/commands/compile/ast/controller.js#L10) and it's true because of: #904
That will keep the new lines for debugging purposes. Sadly the ticket is not there https://jira-archive.titaniumsdk.com/TIMOB-19848 (guess it was private)

@m1ga m1ga marked this pull request as draft April 28, 2025 12:38
@m1ga
Copy link
Contributor Author

m1ga commented Apr 28, 2025

@hansemannn now I pass deployType == production as a parameter to the AST compiler and only for a production build I will set retainLines to false.

To test it: build a dev build and check /Resources/android/alloy/controllers/index.js and build a dist build. Empty lines will be removed when you do a dist build

@m1ga m1ga marked this pull request as ready for review April 28, 2025 12:47
@hansemannn hansemannn merged commit cc7596e into master Apr 28, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants